import { Component, OnInit } from "@angular/core";
import { Hero } from "./hero";
import { HeroService } from "../hero.service";

@Component({
  selector: "app-heroes",
  templateUrl: "./heroes.component.html",
  styleUrls: ["./heroes.component.css"]
})
export class HeroesComponent implements OnInit {
  constructor(private service: HeroService) {}

  ngOnInit() {
    this.setHeroes();
  }
  hero: Hero = {
    id: 1,
    name: "whr"
  };
  setHeroes(): void {
    this.heroes = this.service.getHeroes();
  }

  selectedHero: Hero;

  onSelect(hero: Hero): void {
    this.selectedHero = hero;
  }
}
